package swm.enterprise.rest.repdemo.resources;

import java.util.Date;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import swm.enterprise.rest.repdemo.model.Employee;

@Path("employee")
public class EmployeeResource {
	final Logger logger = LoggerFactory.getLogger(EmployeeResource.class);
	
	@GET
	@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
	public Employee outputEmployee(){
		Employee e = new Employee();
		e.setFirstName("태완");
		e.setLastName("김");
		e.setTitle("개발자");
		e.setHireDate(new Date());
		
		return e;
	}
	
	@POST
	@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
//	@Consumes({MediaType.APPLICATION_JSON,})
	public String inputEmployee(Employee e){
		//logger.info(e.toString());
		return e.toString();
	}
	
	@Path("ext")
	@POST
	@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
	@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
	public Employee inputEmployeeReturn(Employee e){
		//logger.info(e.toString());
		return e;
	}
	
}
